package main

func main() {

	println(isAnagram("rat", "car"))
}

func isAnagram(s string, t string) bool {

	m := make(map[rune]int)

	for _, v := range s {
		if _, ok := m[v]; ok {
			m[v]++
			continue
		}
		m[v] = 1
	}

	for _, v := range t {
		if _, ok := m[v]; ok {
			m[v]--
			if m[v] == 0 {
				delete(m, v)
			}
		} else {
			return false
		}
	}

	return len(m) == 0
}
